/**
 * 
 */
package com.blog.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.blog.pojo.SysMenu;
import com.blog.service.SysMenuService;
 
@Controller
@RequestMapping("config")
public class PermissionController {
    @Autowired SysMenuService sysMenuService;
     
    @RequestMapping("listPermission")
    public String list(Model model){
        List<SysMenu> ps= sysMenuService.list();
        model.addAttribute("ps", ps);
        return "listPermission";
    }
    @RequestMapping("editPermission")
    public String list(Model model,long id){
        SysMenu menu =sysMenuService.get(id);
        model.addAttribute("permission", menu);
        return "editPermission";
    }
    @RequestMapping("updatePermission")
    public String update(SysMenu permission){
 
    	sysMenuService.update(permission);
        return "redirect:listPermission";
    }
 
    @RequestMapping("addPermission")
    public String list(Model model,SysMenu permission){
        System.out.println(permission.getName());
        System.out.println(permission.getUrl());
        sysMenuService.add(permission);
        return "redirect:listPermission";
    }
    @RequestMapping("deletePermission")
    public String delete(Model model,long id){
    	sysMenuService.delete(id);
        return "redirect:listPermission";
    }   
 
}
